<?php
$loader->requireOnce('includes/EnumerationConstant.class.php');
$loader->requireOnce('includes/Utils.class.php');
/**
 * Object Relational Persistence Mapping Class for table: patient_transfer_history_detail
 *
 * @package	com.athena
 * @author	LHV
 */
class PatientTransferHistoryDetail extends ORDataObject {

	/**#@+
	 * Fields of table: patient_transfer_history_detail mapped to class members
	 */
	var $patient_transfer_history_detail_id		= '';
	var $enum_status		= '';
	var $date_time		= '';
	var $patient_transfer_history_id		= '';
	var $in		= '';
	/**#@-*/


	/**
	 * DB Table
	 */
	var $_table = 'patient_transfer_history_detail';

	/**
	 * Primary Key
	 */
	var $_key = 'patient_transfer_history_detail_id';

	/**
	 * Internal Name
	 */
	var $_internalName = 'PatientTransferHistoryDetail';

	/**
	 * Handle instantiation
	 */
	function __construct() {
		parent::ORDataObject();
	}

	public function getHisDetail($ticketId, $keyEnumStatus) {
		$ds = new Datasource_sql();

		$sql = array(
            'cols'  => "patient_transfer_history_detail_id, p.patient_transfer_history_id",
            'from'  => "patient_transfer_history p INNER JOIN $this->_table pd ON (p.ticket_id = '" . $ticketId 
		. "' AND p.patient_transfer_history_id = pd.patient_transfer_history_id)" ,
            'where' => "enum_status = '" . $keyEnumStatus . "'"
            );
             
            $ds->setup($this->_db, $sql);
            $result = $ds->toArray();
            if (empty($result)) {

            	return null;
            }
            return $result[0];

	}

	public function addNew($data = array()) {
		$this->populateArray($data);
		$this->persist();
		return $this->get_id();

	}






}
?>
